﻿using WorkSummary.Common.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WorkSummary.Common.log
{
    public static class log
    {
        public static void info(string UserAcc, string Opt, string Info)
        {
            write(UserAcc, Opt, Info, "INFO", "");
        }
        public static void error(Exception Ex)
        {
            write("", "", "", "ERROR", Ex.ToString());
        }
        public static void error(string Info, Exception Ex)
        {
            write("", "", Info, "ERROR", Ex.ToString());
        }
        public static void error(string Opt, string Info, Exception Ex)
        {
            write("", Opt, Info, "ERROR", Ex.ToString());
        }
        public static void error(string UserAcc, string Opt, string Info, Exception Ex)
        {
            write(UserAcc, Opt, Info, "ERROR", Ex.ToString());
        }
        private static void write(string UserAcc, string Opt, string Info, string Level, string Ex)
        {
            MLog M = new MLog();
            M.UserAcc = UserAcc;
            M.Opt = Opt;
            M.Info = Info.Replace("\'", "");
            M.Level = Level;
            M.Ex = Ex.Replace("\'", "\'\'");
            //string sql = string.Format("insert into T_SysLog (UserAcc,LogTime,Opt,Info,Level,ThreadNum,Ex) Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", M.UserAcc, M.LogTime, M.Opt, M.Info, M.Level, M.ThreadNum, M.Ex);
            //DbUtils.ExecuteNonQuery(sql);
            DbUtils.InsertNoIdentity(M);
        }
    }

    public enum Operating
    {
        
    }
}
